<?php

$html = '<div class="userProfile"><h2>Регистрация</h2></div>';
$html .= '<div class="register">
    <div class="registerInside">
        <form method="POST" action="index.php?p=register">
            <div>
                Потребителско име:
                <br/>
                <input type="text" name ="username">
            </div>
            <div>
                Парола:
                <br/>
                <input type="password" name="password">
            </div>
            <div>
                <input id="registerSubmit" type="submit" value="Създай профил">
            </div>
        </form>
    </div>
</div>';

if (count($data['errors']) > 0) {
    foreach ($data['errors'] as $error) {
        $html .= '<p class="error">' . $error . '</p>';
    }
}

echo $html;